# -*- coding: utf-8 -*-
from flask import Flask, request, render_template, jsonify
from libs.kit import *
from logic.search import XvSearchLogic

logic = XvSearchLogic()

app = Flask(__name__)

# http://localhost:5000/api/search/p/1/japan+blowjob

@app.route('/api/search/p/<page>/<keyword>')
def api_search_by_page(page, keyword):
    data = logic.do_search(keyword, page)
    return jsonify(data)

# http://localhost:5000/api/video/video34542905-mothers_fucked_in_front_of_their_daughters
@app.route('/api/video/<url>')
def api_get_video(url):
    url = url.replace('-', '/')
    data = logic.get_video(url)
    return jsonify({'origin_mp4': data})

@app.route('/')
def get_index():
    return render_template('search.html')

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=5555, debug=True) 